package com.wicket.okrframework.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wicket.okrframework.common.annotations.BanAuto;
import com.wicket.okrframework.common.dto.FieldInfo;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wicket.okrframework.base.service.MDeptService;
import com.wicket.okrframework.common.exception.BizException;
import com.wicket.okrframework.common.tools.StringUtils;
import com.wicket.okrframework.common.util.CommonFunctionHelper;
import com.wicket.okrframework.dal.mapper.mbg.DeptMapper;
import com.wicket.okrframework.dal.po.mbg.Dept;
import com.wicket.okrframework.base.service.dto.req.*;
//import com.wicket.okrframework.base.service.dto.res.*;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ：
 * @since 2022/1/19 15:39
 *
 *
 * @version 1.0
 */
@Service
public class MDeptServiceImpl
  extends ServiceImpl<DeptMapper, Dept>
  implements MDeptService {

  @Autowired
  DeptMapper deptMapper;
/**
   * 1-3-09新增部门[214]
   * gen by moon at 10/23/2022, 2:26:20 PM
   */
 @Trace(operationName = "1-3-09新增部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  String  addDept(Dept dept) {
     dept.setDeptId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
dept.setDeptCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
dept.setIsArchive("FALSE");
dept.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
dept.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
if(dept!=null && dept.getSubjectLifeCycle()!=null &&  dept.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            dept.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
          }
dept.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
dept.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
if(dept!=null && dept.getSubjectLifeCycle()!=null && dept.getSubjectLifeCycle().equals("CURRENTLY_VALID")){
             dept.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
            }
dept.setIsValid("FALSE");
dept.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
dept.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
     if(super.save(dept)){
        return dept.getDeptId();
     }else {
        return "-1";
     }
    
  }
/**
   * 1-3-09修改部门[215]
   * gen by moon at 10/23/2022, 2:26:21 PM
   */
 @Trace(operationName = "1-3-09修改部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  updateDept(Dept dept) {
     dept.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
if(dept!=null && dept.getSubjectLifeCycle()!=null &&  dept.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            dept.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
          }
if(dept!=null && dept.getSubjectLifeCycle()!=null && dept.getSubjectLifeCycle().equals("ARCHIVING")) {
              dept.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
          }
dept.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
if(dept!=null && dept.getSubjectLifeCycle()!=null && dept.getSubjectLifeCycle().equals("CURRENTLY_VALID")){
             dept.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
            }
if(dept!=null && dept.getSubjectLifeCycle()!=null && dept.getSubjectLifeCycle().equals("ARCHIVING")) {
              dept.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
          }
        return super.updateById(dept);
  }
/**
   * 1-3-09删除部门[216]
   * gen by moon at 10/23/2022, 2:26:21 PM
   */
 @Trace(operationName = "1-3-09删除部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  deleteDept(String deptId ) {
     
      return super.removeById(deptId);
  }
/**
   * 1-3-09查询部门列表[217]
   * gen by moon at 10/23/2022, 2:26:22 PM
   */
 @Trace(operationName = "1-3-09查询部门列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  queryDeptList(QueryDeptListReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
queryWrapper.orderByDesc("operate_time");
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09查询部门详情[218]
   * gen by moon at 3/31/2023, 3:24:05 AM
   */
 @Trace(operationName = "1-3-09查询部门详情")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  Dept  queryDeptDetail(QueryDeptDetailReq reqDto) {
     
        try {
         reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<Dept> retList = super.list(queryWrapper);
            if(retList!=null && retList.size()>0){
                Dept retData = retList.get(0);
                
                return retData;
            }
            return null;
      } catch (Exception e) {
          e.printStackTrace();
          throw new BizException("-1",e,false);
      }
  }
/**
   * 1-3-09批量查询部门列表[1153]
   * gen by moon at 10/23/2022, 2:26:24 PM
   */
 @Trace(operationName = "1-3-09批量查询部门列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQueryDeptList(BatchQueryDeptListReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("dept_id", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
queryWrapper.orderByDesc("operate_time");
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09批量查询部门列表[1515]
   * gen by moon at 10/23/2022, 2:26:25 PM
   */
 @Trace(operationName = "1-3-09批量查询部门列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQueryDept(BatchQueryDeptReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("dept_code", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * M-构造部门树状结构特殊方法[1522]
   * gen by moon at 10/23/2022, 2:26:25 PM
   */
 @Trace(operationName = "M-构造部门树状结构特殊方法")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  querySpecMethodTreeList(QuerySpecMethodTreeListReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            queryWrapper.in("dept_id", reqDto.getDeptList().stream().map(DeptDto::getDeptId).collect(Collectors.toList()));
queryWrapper.in("dept_code", reqDto.getDeptList().stream().map(DeptDto::getDeptCode).collect(Collectors.toList()));
queryWrapper.in("parent_dept_id", reqDto.getDeptList().stream().map(DeptDto::getParentDeptId).collect(Collectors.toList()));
queryWrapper.in("level_number", reqDto.getDeptList().stream().map(DeptDto::getLevelNumber).collect(Collectors.toList()));
queryWrapper.in("dept_name", reqDto.getDeptList().stream().map(DeptDto::getDeptName).collect(Collectors.toList()));
queryWrapper.in("organization_id", reqDto.getDeptList().stream().map(DeptDto::getOrganizationId).collect(Collectors.toList()));
queryWrapper.in("is_create_lower_dept", reqDto.getDeptList().stream().map(DeptDto::getIsCreateLowerDept).collect(Collectors.toList()));
queryWrapper.in("order_number", reqDto.getDeptList().stream().map(DeptDto::getOrderNumber).collect(Collectors.toList()));
queryWrapper.in("is_directly_member", reqDto.getDeptList().stream().map(DeptDto::getIsDirectlyMember).collect(Collectors.toList()));
queryWrapper.in("dept_number", reqDto.getDeptList().stream().map(DeptDto::getDeptNumber).collect(Collectors.toList()));
queryWrapper.in("dept_en_name", reqDto.getDeptList().stream().map(DeptDto::getDeptEnName).collect(Collectors.toList()));
queryWrapper.in("dept_short_name", reqDto.getDeptList().stream().map(DeptDto::getDeptShortName).collect(Collectors.toList()));
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09模糊查询部门列表[1570]
   * gen by moon at 10/23/2022, 2:26:26 PM
   */
 @Trace(operationName = "1-3-09模糊查询部门列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  vagueQueryDept(VagueQueryDeptReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09查询一级部门列表ByIds（暂没有使用，以后预留）[1762]
   * gen by moon at 10/23/2022, 2:26:27 PM
   */
 @Trace(operationName = "1-3-09查询一级部门列表ByIds（暂没有使用，以后预留）")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQueryOneLevelDeptListByIds(BatchQueryOneLevelDeptListByIdsReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("type_dictionary_id", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09查询部门树状结构列表[1846]
   * gen by moon at 10/23/2022, 2:26:29 PM
   */
 @Trace(operationName = "1-3-09查询部门树状结构列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
 @BanAuto
  public  List<Dept>  queryDeptTreeList(QueryDeptTreeListReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);

            for (FieldInfo columnInfo : likeList) {
                queryWrapper.likeRight(columnInfo.getName(), fieldInfoMap.get(columnInfo.getName()));
            }
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("order_number");
queryWrapper.orderByDesc("operate_time");
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09批量查询下级直属部门[4104]
   * gen by moon at 10/23/2022, 2:26:29 PM
   */
 @Trace(operationName = "1-3-09批量查询下级直属部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQuerySubordinateDirectlyDept(BatchQuerySubordinateDirectlyDeptReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("parent_dept_id", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * M1去重过滤已存在的部门[4106]
   * gen by moon at 10/23/2022, 2:26:30 PM
   */
 @Trace(operationName = "M1去重过滤已存在的部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  unrepeatedFilterExistingDept(UnrepeatedFilterExistingDeptReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("dept_id", reqDto.getDeptList());
if(reqDto.getSubordinateDeptList()==null || reqDto.getSubordinateDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("parent_dept_id", reqDto.getSubordinateDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09批量改部门主管[4152]
   * gen by moon at 10/23/2022, 2:26:31 PM
   */
 @Trace(operationName = "1-3-09批量改部门主管")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchUpdateDeptDirector(List<Dept> dept) {
     
      if(dept==null || dept.size()==0){
        return false;
      }
        return super.saveOrUpdateBatch(dept);
      
  }
/**
   * 1-3-09批量改部门[4387]
   * gen by moon at 10/23/2022, 2:26:32 PM
   */
 @Trace(operationName = "1-3-09批量改部门")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchUpdateDept(List<Dept> dept) {
     
      if(dept==null || dept.size()==0){
        return false;
      }
        return super.saveOrUpdateBatch(dept);
      
  }
/**
   * 1-3-1查询下级直属部门详情[4773]
   * gen by moon at 3/31/2023, 3:24:05 AM
   */
 @Trace(operationName = "1-3-1查询下级直属部门详情")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  Dept  querySubordinateDirectlyDeptDetail(QuerySubordinateDirectlyDeptDetailReq reqDto) {
     
        try {
         reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<Dept> retList = super.list(queryWrapper);
            if(retList!=null && retList.size()>0){
                Dept retData = retList.get(0);
                
                return retData;
            }
            return null;
      } catch (Exception e) {
          e.printStackTrace();
          throw new BizException("-1",e,false);
      }
  }
/**
   * M1查询部门测试列表[4897]
   * gen by moon at 2/19/2023, 1:31:58 PM
   */
 @Trace(operationName = "M1查询部门测试列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  queryDeptTestDataList(QueryDeptTestDataListReq reqDto) {
     
        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            
            
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            
            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * M1批量删部门测试[4898]
   * gen by moon at 10/23/2022, 2:26:34 PM
   */
 @Trace(operationName = "M1批量删部门测试")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  batchDeleteDeptTestData(List<String> reqDto) {
     
          if(reqDto==null || reqDto.size()==0){
            return false;
          }
          
          return super.removeByIds(reqDto);
  }
/**
   * 1-3-09批量查询部门列表ByCode[6306]
   * gen by moon at 4/17/2023, 11:50:54 PM
   */
 @Trace(operationName = "1-3-09批量查询部门列表ByCode")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQueryDeptByCode(BatchQueryDeptByCodeReq reqDto) {

        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("dept_code", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09查询组织下部门列表[7228]
   * gen by moon at 6/22/2023, 4:42:23 PM
   */
 @Trace(operationName = "1-3-09查询组织下部门列表")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  queryOrgBelowDeptList(QueryOrgBelowDeptListReq reqDto) {

        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }
/**
   * 1-3-09修改部门清除值[7434]
   * gen by moon at 11/1/2023, 9:44:23 PM
   */
 @Trace(operationName = "1-3-09修改部门清除值")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  boolean  updateDeptClear(Dept dept) {

        return super.updateById(dept);
  }
/**
   * 1-3-09批量查询部门By主键ID[9096]
   * gen by moon at 4/2/2024, 11:30:10 PM
   */
 @Trace(operationName = "1-3-09批量查询部门By主键ID")
 @Tags({@Tag(key = "参数",value = "arg[0]"),
 @Tag(key = "返回值",value = "returnedObj")})
  @Override
  @Transactional(rollbackFor=Exception.class)
  public  List<Dept>  batchQueryDeptByEntiyId(BatchQueryDeptByEntiyIdReq reqDto) {

        try {
            QueryWrapper<Dept> queryWrapper = new QueryWrapper<>();

            if(reqDto.getDeptList()==null || reqDto.getDeptList().isEmpty()){
                    return new ArrayList<>();
                }
        queryWrapper.in("dept_id", reqDto.getDeptList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(Dept.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(Dept.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper,likeList,fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap,likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(Dept.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<Dept>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1",e,false);
        }
  }

}

